<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>Document</title>
	<style type="text/css">
		* {
			margin: 0;
			padding: 0;
			box-sizing: border-box;
		}

		.container {
			display: flex;
			justify-content: center;
			align-items: center;
			width: 100vw;
			height: 100vh;
		}

		.wrapper {
			position: relative;
			width: 400px;
			height: 400px;
			background: #fff url('../imgs/clock.png') no-repeat center;
			background-size: 100% 100%;
		}

		.hour-hand,
		.minute-hand,
		.second-hand {
			position: absolute;
			right: 0;
			left: 0;
			bottom: 50%;
			margin: auto;
			transform-origin: bottom center;
			border-radius: 4px;
		}

		.hour-hand {
			width: 6px;
			height: 100px;
			background-color: #333;
			z-index: 3;
		}

		.minute-hand {
			width: 4px;
			height: 116px;
			background-color: #333;
			z-index: 2;
		}

		.second-hand {
			width: 2px;
			height: 120px;
			background-color: #f01414;
			z-index: 1;
		}
	</style>
</head>

<body>
	<div class="container">
		<div class="wrapper">
			<div class="hour-hand"></div>
			<div class="minute-hand"></div>
			<div class="second-hand"></div>
		</div>
	</div>

	<script>
		var hourEl = document.querySelector('.hour-hand');
		var minuteEl = document.querySelector('.minute-hand');
		var secondEl = document.querySelector('.second-hand');

		showTime();
		setInterval(showTime, 1000);

		function showTime() {
			var date = new Date();

			var hour = date.getHours();
			var minute = date.getMinutes();
			var second = date.getSeconds();

			// hourEl.style.transform = `rotate(${hour * 30}deg)`;
			// minuteEl.style.transform = `rotate(${minute * 6}deg)`;
			// secondEl.style.transform = `rotate(${second * 6}deg)`;

			// 缓慢过渡的过程
			hourEl.style.transform = `rotate(${hour * 30 + (minute / 60) * 30}deg)`;
			minuteEl.style.transform = `rotate(${minute * 6 + (second / 60) * 6}deg)`;
			secondEl.style.transform = `rotate(${second * 6}deg)`;
		}

	</script>
</body>

</html>